from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.remote.webdriver import WebDriver

from base.base_page import BasePage
from page.search_page import SearchPage


class SelectSubjectPage(BasePage):
    """
    选择学科页
    """
    # 高级tab
    _higher = (AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.widget.ListView/android.view.View[1]")
    # 高级——信息系统项目管理工程师
    _higher_xinxixitongxiangmuguanlishi = (AppiumBy.XPATH,
                                           "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]/android.view.View/android.widget.ListView/android.view.View[5]/android.view.View")
    # 中级tab
    _secondary = (AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.widget.ListView/android.view.View[2]")
    # 中级——数据库系统工程师
    _secondary_database_system_engineer = (AppiumBy.XPATH,
                                           "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]/android.view.View/android.widget.ListView/android.view.View[7]/android.view.View")
    # 初级tab
    _primary = (AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.widget.ListView/android.view.View[3]")

    def back_to_main_page(self):
        """
        步骤：选择“中级”——“数据库系统工程师”
        :return: 首页
        """
        self.find_element_and_click(self._secondary)
        self.find_element_and_click(self._secondary_database_system_engineer)
        # return MainPage(self.driver)
        return self
